<%@page import="org.springframework.security.core.context.SecurityContextHolder"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	UserInfo user = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	String username = user.getName();
	String siteid = user.getSiteId();
	String defaultSiteId = request.getAttribute("defaultSiteId")+"";
%>

<style>
	.selectHour-split{
		padding:0 2px;
		margin-right:5px;	
	}
	.selectMinute-split{
		padding:0 2px;
	}
	.tr_shift_s{
		background: #f2f2f2;
	}
</style>

<div>
	<form id="LeaveAddForm" target="_coreIframe" method="post" action="<%=request.getContextPath()%>/check/doAddShift" enctype="multipart/form-data">
		<div class="breadcrumb">
			<div class="bcIcon"></div>
			<ul class="bcNav">
				<li>增加班次（指一个星期的上班计划）</li>
			</ul>
		</div>
		<table class="formTable">
			<tr>
				<td class="tdTitle">所属公司：</td>
				<td>
					<select id="siteList" class="easyui-combobox" name="siteid" style="width:100px;"></select>
					<span class="errorTipWrap" id="errorTip_userid"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">班次名称：</td>
				<td><input class="inputText xxs" type="text"  value="" name="shiftName">
			</tr>
			<tr>
				<td>
				</td>
				<td>
					<span>第一个上班时间段设置（比如上午）</span>
					<a class="a-btn-gray-small" href="javascript:XF.Check.setShift('f')">尝试默认设置</a>
					<a class="a-btn-gray-small" href="javascript:XF.Check.usetShift('f')">清空设置</a>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">上班打卡时间：</td>
				<td>
					<select sss="checkintime_hour" id="fCheckintime_hour"class="easyui-combobox" name="fCheckintime_hour" style="width:100px;"></select><span class="selectHour-split">时</span>
					<select sss="checkintime_minute" id="fCheckintime_minute" class="easyui-combobox" name="fCheckintime_minute" style="width:100px;"></select><span class="selectMinute-split">分</span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">下班打开时间：</td>
				<td>
					<select sss="checkintime_hour" id="fCheckouttime_hour" class="easyui-combobox" name="fCheckouttime_hour" style="width:100px;"></select><span class="selectHour-split">时</span>
					<select sss="checkintime_minute" id="fCheckouttime_minute" class="easyui-combobox" name="fCheckouttime_minute" style="width:100px;"></select><span class="selectMinute-split">分</span>
				</td>
			</tr>			
			<tr>
				<td class="tdTitle">计算迟到：</td>
				<td>
					<select sss="laterMinute" id="fLaterMinute" class="easyui-combobox" name="fLaterMinute" style="width:100px;"></select><span class="selectMinute-split">分钟</span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">计算早退：</td>
				<td>
					<select sss="laterMinute" id="fEarlierMinute" class="easyui-combobox" name="fEarlierMinute" style="width:100px;"></select><span class="selectMinute-split">分钟</span>
				</td>
			</tr>
<!-- 			<tr>
				<td class="tdTitle">有效提前打卡：</td>
				<td>
					<select sss="AllowEarlierMinute" id="fAllowEarlierMinute" class="easyui-combobox" name="fAllowEarlierMinute" style="width:100px;"></select><span class="selectMinute-split">分钟</span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">有效推迟打卡：</td>
				<td>
					<select sss="AllowEarlierMinute" id="fAllowLaterMinute" class="easyui-combobox" name="fAllowLaterMinute" style="width:100px;"></select><span class="selectMinute-split">分钟</span>
				</td>
			</tr> -->
			<tr>
				<td class="tdTitle">是否考勤设置：</td>
				<td class="" colspan="2">
						<div class="checkbox-wrap">
							<label>
								<input id="setTop" type="checkbox" value="1" name="fAsLate" class="checkbox">
								<span>考勤上班</span>
							</label>
							<label>
								<input id="setImportant" type="checkbox" value="1" name="fAsEarly" class="checkbox">
								<span>考勤下班</span>
							</label>
						</div>
					</td>
			</tr>
			<tr>
				<td class="tdTitle">计算工作天：</td>
				<td>
					<select sss="checkedDays" id="fCheckedDays" class="easyui-combobox" name="fCheckedDays" style="width:100px;"></select><span class="selectMinute-split">天</span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">考勤日：</td>
				<td class="" colspan="2">
					<div class="checkbox-wrap">
						<input type="hidden" name="fWorkDay">
						<label>
							<input type="checkbox" class="checkbox fWorkDay_checkbox" s="1">
							<span>星期一</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox fWorkDay_checkbox" s="2">
							<span>星期二</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox fWorkDay_checkbox" s="3">
							<span>星期三</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox fWorkDay_checkbox" s="4">
							<span>星期四</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox fWorkDay_checkbox" s="5">
							<span>星期五</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox fWorkDay_checkbox" s="6">
							<span>星期六</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox fWorkDay_checkbox" s="0">
							<span>星期日</span>
						</label>
					</div>
				</td>
			</tr>
			
			<tr class="tr_shift_s">
				<td>
				</td>
				<td>
					<span>第二个上班时间段设置（比如下午）</span>
					<a class="a-btn-gray-small" href="javascript:XF.Check.setShift('s')">尝试默认设置</a>
					<a class="a-btn-gray-small" href="javascript:XF.Check.usetShift('s')">清空设置</a>
				</td>
			</tr>
			<tr class="tr_shift_s">
				<td class="tdTitle">上班打卡时间：</td>
				<td>
					<select sss="checkintime_hour"  id="sCheckintime_hour" class="easyui-combobox" name="sCheckintime_hour" style="width:100px;"></select><span class="selectHour-split">时</span>
					<select sss="checkintime_minute" id="sCheckintime_minute" class="easyui-combobox" name="sCheckintime_minute" style="width:100px;"></select><span class="selectMinute-split">分</span>
				</td>
			</tr>
			<tr class="tr_shift_s">
				<td class="tdTitle">下班打开时间：</td>
				<td>
					<select sss="checkintime_hour"  id="sCheckouttime_hour" class="easyui-combobox" name="sCheckouttime_hour" style="width:100px;"></select><span class="selectHour-split">时</span>
					<select sss="checkintime_minute" id="sCheckouttime_minute" class="easyui-combobox" name="sCheckouttime_minute" style="width:100px;"></select><span class="selectMinute-split">分</span>
				</td>
			</tr>			
			<tr class="tr_shift_s">
				<td class="tdTitle">计算迟到：</td>
				<td>
					<select sss="laterMinute" id="sLaterMinute" class="easyui-combobox" name="sLaterMinute" style="width:100px;"></select><span class="selectMinute-split">分钟</span>
				</td>
			</tr>
			<tr class="tr_shift_s">
				<td class="tdTitle">计算早退：</td>
				<td>
					<select sss="laterMinute" id="sEarlierMinute" class="easyui-combobox" name="sEarlierMinute" style="width:100px;"></select><span class="selectMinute-split">分钟</span>
				</td>
			</tr>
<!-- 			<tr class="tr_shift_s">
				<td class="tdTitle">允许提前打卡：</td>
				<td>
					<select sss="AllowEarlierMinute" id="sAllowEarlierMinute" class="easyui-combobox" name="sAllowEarlierMinute" style="width:100px;"></select><span class="selectMinute-split">分钟</span>
				</td>
			</tr>
			<tr class="tr_shift_s">
				<td class="tdTitle">允许推迟打卡：</td>
				<td>
					<select sss="AllowEarlierMinute" id="sAllowLaterMinute" class="easyui-combobox" name="sAllowLaterMinute" style="width:100px;"></select><span class="selectMinute-split">分钟</span>
				</td>
			</tr> -->
			<tr class="tr_shift_s">
				<td class="tdTitle">是否考勤设置：</td>
				<td class="" colspan="2">
						<div class="checkbox-wrap">
							<label>
								<input id="setTop" type="checkbox" value="1" name="sAsLate" class="checkbox">
								<span>考勤上班</span>
							</label>
							<label>
								<input id="setImportant" type="checkbox" value="1" name="sAsEarly" class="checkbox">
								<span>考勤下班</span>
							</label>
						</div>
					</td>
			</tr>
			<tr class="tr_shift_s">
				<td class="tdTitle">计算工作天：</td>
				<td>
					<select sss="checkedDays" id="sCheckedDays" class="easyui-combobox" name="sCheckedDays" style="width:100px;"></select><span class="selectMinute-split">天</span>
				</td>
			</tr>
			<tr class="tr_shift_s">
				<td class="tdTitle">考勤日：</td>
				<td class="" colspan="2">
					<div class="checkbox-wrap">
						<input type="hidden" name="sWorkDay">
						<label>
							<input type="checkbox" class="checkbox sWorkDay_checkbox" s="1">
							<span>星期一</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox sWorkDay_checkbox" s="2">
							<span>星期二</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox sWorkDay_checkbox" s="3">
							<span>星期三</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox sWorkDay_checkbox" s="4">
							<span>星期四</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox sWorkDay_checkbox" s="5">
							<span>星期五</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox sWorkDay_checkbox" s="6">
							<span>星期六</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox sWorkDay_checkbox" s="0">
							<span>星期日</span>
						</label>
					</div>
				</td>
			</tr>
			
			<tr>
				<td>
				</td>
				<td>
					<span>第三个上班时间段设置（比如夜间）</span>
					<a class="a-btn-gray-small" href="javascript:XF.Check.setShift('t')">尝试默认设置</a>
					<a class="a-btn-gray-small" href="javascript:XF.Check.usetShift('t')">清空设置</a>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">上班打卡时间：</td>
				<td>
					<select sss="checkintime_hour" id="tCheckintime_hour"class="easyui-combobox" name="tCheckintime_hour" style="width:100px;"></select><span class="selectHour-split">时</span>
					<select sss="checkintime_minute" id="tCheckintime_minute" class="easyui-combobox" name="tCheckintime_minute" style="width:100px;"></select><span class="selectMinute-split">分</span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">下班打开时间：</td>
				<td>
					<select sss="checkintime_hour" id="tCheckouttime_hour" class="easyui-combobox" name="tCheckouttime_hour" style="width:100px;"></select><span class="selectHour-split">时</span>
					<select sss="checkintime_minute" id="tCheckouttime_minute" class="easyui-combobox" name="tCheckouttime_minute" style="width:100px;"></select><span class="selectMinute-split">分</span>
				</td>
			</tr>			
			<tr>
				<td class="tdTitle">计算迟到：</td>
				<td>
					<select sss="laterMinute" id="tLaterMinute" class="easyui-combobox" name="tLaterMinute" style="width:100px;"></select><span class="selectMinute-split">分钟</span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">计算早退：</td>
				<td>
					<select sss="laterMinute" id="tEarlierMinute" class="easyui-combobox" name="tEarlierMinute" style="width:100px;"></select><span class="selectMinute-split">分钟</span>
				</td>
			</tr>
<!-- 			<tr>
				<td class="tdTitle">允许提前打卡：</td>
				<td>
					<select sss="AllowEarlierMinute" id="tAllowEarlierMinute" class="easyui-combobox" name="tAllowEarlierMinute" style="width:100px;"></select><span class="selectMinute-split">分钟</span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">允许推迟打卡：</td>
				<td>
					<select sss="AllowEarlierMinute" id="tAllowLaterMinute" class="easyui-combobox" name="tAllowLaterMinute" style="width:100px;"></select><span class="selectMinute-split">分钟</span>
				</td>
			</tr> -->
			<tr>
				<td class="tdTitle">是否考勤设置：</td>
				<td class="" colspan="2">
						<div class="checkbox-wrap">
							<label>
								<input id="setTop" type="checkbox" value="1" name="tAsLate" class="checkbox">
								<span>考勤上班</span>
							</label>
							<label>
								<input id="setImportant" type="checkbox" value="1" name="tAsEarly" class="checkbox">
								<span>考勤下班</span>
							</label>
						</div>
					</td>
			</tr>
			<tr>
				<td class="tdTitle">计算工作天：</td>
				<td>
					<select sss="checkedDays" id="tCheckedDays" class="easyui-combobox" name="tCheckedDays" style="width:100px;"></select><span class="selectMinute-split">天</span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">考勤日：</td>
				<td class="" colspan="2">
					<div class="checkbox-wrap">
						<input type="hidden" name="tWorkDay">
						<label>
							<input type="checkbox" class="checkbox tWorkDay_checkbox" s="1">
							<span>星期一</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox tWorkDay_checkbox" s="2">
							<span>星期二</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox tWorkDay_checkbox" s="3">
							<span>星期三</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox tWorkDay_checkbox" s="4">
							<span>星期四</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox tWorkDay_checkbox" s="5">
							<span>星期五</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox tWorkDay_checkbox" s="6">
							<span>星期六</span>
						</label>
						<label>
							<input type="checkbox" class="checkbox tWorkDay_checkbox" s="0">
							<span>星期日</span>
						</label>
					</div>
				</td>
			</tr>
			
			<tr>
			<td class="tdTitle"></td>
			<td>
				<div>
					<input class="input-btn-microsoft" type="submit" value="提交">
					<a class="a-btn-microsoft" href="javascript:XF.NAV.navTo('/check')">取消</a>
				</div>
			</td>
		</tr>	
		</table>
		<input type="hidden" value="<%=username %>" name="addUser"> 	
	</form>
	<iframe id="_coreIframe" name="_coreIframe" style="display: none;"></iframe>
</div>
<script>
$('#siteList').combobox({
	url:global.contextPath + '/company/siteList',
	valueField:'siteid',
	textField:'sitename',
});

$('select[sss=checkintime_hour]').combobox({
	url:global.contextPath + '/check/allHour',
	valueField:'hourId',
	textField:'hourName',
});

$('select[sss=checkintime_minute]').combobox({
	url:global.contextPath + '/check/allMinute',
	valueField:'minuteId',
	textField:'minuteName',
});

$('select[sss=laterMinute]').combobox({
	url:global.contextPath + '/check/laterMinute',
	valueField:'minuteId',
	textField:'minuteName',
});
$('select[sss=AllowEarlierMinute]').combobox({
	url:global.contextPath + '/check/elareyMinute',
	valueField:'minuteId',
	textField:'minuteName',
});
$('select[sss=checkedDays]').combobox({
	url:global.contextPath + '/check/checkedDays',
	valueField:'dayId',
	textField:'dayName',
});
$('#siteList').combobox('setValue', '<%=defaultSiteId %>');
XF.Check.init();
</script>


